<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
    
        function Person(name,age) {
            this.name = name;
            this.age = age;
            this.changge = function () {
                console.log(this.name + ':忘情水');                
            }
        }
        var p1 = new Person('刘德华','59');

        //创建学生构造函数
        function Student(num) {
            this.num = num;
        }
        
        Student.prototype.extend = function(obj) {
            for(var k in obj) {
                this[k] = obj[k];
            }
        }

        //实例化一个学生
        var stu = new Student('110');
        //学生需要 继承 人有的属性和方法（p1 刘德华这个人的属性和方法）
        stu.extend(p1);
        stu.changge()

        console.log(stu);
        
    </script>
</body>
</html>